<include file="./Application/Home/View/Common/backup/header_nav.html" />


<script type="text/javascript">
/*
 * 首页头部javascript
 */
;(function(me, lm, $ip) {
    function afterSubmit() {
      ai.modal('hide');
      $('form', ai).each(function() {
        this.reset();
      });
      $('#input_url', ai).val('');
    }
    var ai = $('#article_import.article_import_modal');
    var docType = {
            word: function() {
                var from = document.getElementById('data_sub_frm');
                wordSubmit.submit.call(from, function(data) {
                    $('#doc_text', ai).val(escape(data)).parent()[0].submit();
                    afterSubmit();
                });
            },
            wechat: function() {
                var url = $('#input_url', ai).val();
                if(WeChatArtURLCheck.check(url)) {
                    window.open('/editText?edit_type=1&remotoUrl=' + escape(url), 'remotoArt');
                    afterSubmit();
                }
            }
        };

    me.on('click', '.search_area .search_item', function() {
        // var left = $(this).position().left || 0,
           var width = $(this).outerWidth();
        // $(this).addClass('selected').siblings().removeClass('selected');
        $('.bg_tool', $(this).parent()).css({
            // 'left': left,
            'width': width,
            // 'display':'block'
        });

        $('.search_area #fm_search_type').val($(this).attr('kw'));
        //点击到相应的页面
        //$('.search_link').trigger('click');
        var head_search_type=$(this).attr('kw');
        var head_search_key=encodeURI($('.search_ipt').val());
        var address_array={'art':'/search/articles?search_type=art','image':'/search/images?search_type=image','gzh':'/search/account?search_type=gzh','tpc':'/topic'};
        var search_address=address_array[head_search_type];
        if ($('.search_ipt').val() == '') {
            if (head_search_type == 'tpc') {
                window.open(search_address, 'search_art');
            } else {
                window.open(search_address + '&from_nav=1', 'search_art');
            }
        } else {
            if (head_search_type == 'tpc') {
                window.open(search_address+'/search?keyword=' + head_search_key, 'search_art');
            } else {
                window.open(search_address + '&search_key=' + head_search_key, 'search_art');
            }
        }
    });

    $(document).on('click', '.js_article_import', function() {
        ai.modal('show');
    }).on('click', '.js_register_guide', function(e) {
        e.preventDefault();
        $('#register-guide').modal('show');
    });

    ai.on('click', '.js_browse_file', function() {
        $('#doc_file', ai).trigger('click');
    }).on('change', '#import_type', function() {
        var type = $(this).val();
        $('[data-show]', ai).addClass('hide');
        $('[data-show="' + type + '"]', ai).removeClass('hide');
    }).on('click', '.js_OK', function() {
        docType[$('#import_type', ai).val()]();
    }).on('change', '#doc_file', function() {
        var fileName = $(this).val();
        fileName = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length - 1);
        $('.sub_file_name', ai).text(fileName).prop('title', fileName);
    });

    var $before = $('.nav_list .nav_top_list', $ip);
    $('.nav_list .nav_item', $ip).hover(function() {
        var tranfVal = 'translateX(' + $(this).position().left + 'px)';
        var cssStyle = {
            '-webkit-transform': tranfVal,
            '-ms-transform': tranfVal,
            '-o-transform': tranfVal,
            'transform': tranfVal,
            'width': $(this).outerWidth()
        }
        $before.addClass('unopa').css(cssStyle);
    }, function() {
        $before.removeClass('unopa');
    });

    window.startNotice = function(userlogin) {

        if(!userlogin) return;

        var goEasy = new GoEasy({
            appkey: 'b7fb4e5f-98e4-4f9b-98d4-56ea2302158e'
        });
        if (window.localStorage.getItem(userlogin + '_notice') == 1 && $('#frm_header #page_id').val() != 'TLM018') {
            $('#user_notice').addClass('notice_show');
        } else {
            window.localStorage.removeItem(userlogin + '_notice');
            if (window.opener) {
                $('#user_notice', window.opener.document.body).removeClass('notice_show');
            }
        }
        window.localStorage.setItem('IsNotice', 1);
        goEasy.subscribe({
            channel: userlogin + '_channel',
            onMessage: function(message) {
                var json = typeof message.content == 'object' ? message.content : $.parseJSON(message.content);
                var noticeType = false;
                var ua = navigator.userAgent.toLowerCase();
                $('#user_notice').addClass('notice_show');
                if ($('#frm_header #page_id').val() == 'TLM018') {
                    window.location.reload();
                } else {
                    window.localStorage.setItem(userlogin + '_notice', 1);
                }

                if (ua.indexOf('firefox') > -1 || ua.indexOf('edge') > -1) {
                    noticeType = true;
                }

                if (json.select === $('#frm_header #page_id').val()) {
                  window.location.reload();
                }

                if (window.localStorage.getItem('IsNotice') == 1) {
                    ShowTitleMessage.notice(json.title);
                    window.localStorage.setItem('IsNotice', 0);
                    setTimeout("window.localStorage.setItem('IsNotice', 1)", 1e3);
                }
            }
        });
    }

    // 未登录的判断
    $(function() {
        var user_login = $('#frm_header #user_login').val();

        $('.selectpicker', ai).selectpicker(8);

        if (user_login) {
            //通知
            try{
                window.startNotice(user_login);
            }catch(e){

            }
            
        }

        $('.js_unlogin_forward').on('click.js_unlogin_forward', function(e) {
            // ********************************************************************
            // 未登录的状态需要阻止的操作
            // 事件绑定的函数位置务必放在此函数位置之后且作用域务必小于等于document
            e.preventDefault();
            e.stopImmediatePropagation();
            $('.modal.in').removeClass('fade').modal('hide').addClass('fade');
            lm.modal('show');
            window.loginSueccssAndContinue = $.proxy(function() {
                if (this.tagName.toLowerCase() == 'a') {
                    if ($(this).prop('href')) {
                        location.href = $(this).prop('href');
                    }
                } else {
                    $(this).trigger('click');
                }
            }, this);
        });

    });

}($('.header_container_main'), $('#login-modal')), $('.header_container_main.inner_page'));
</script>

<script type="text/javascript">
    var msg = $('.guide_wrap #msg').val();
    var _var=$('input#login_time').val();
    var _ulr=window.location.pathname;
    if (_var == '1' && msg != 'null' && msg) {
        //sessionStorage.pagecount=1;
        //location.href="/resource/article";
        // if(!sessionStorage.article && sessionStorage.article != 1){
        //     sessionStorage.article=1;
        // }
        // if(!sessionStorage.my_mpnews && sessionStorage.my_mpnews != 1){
        //     sessionStorage.my_mpnews=1;
        // }
        // if(!sessionStorage.sending && sessionStorage.sending != 1){
        //     sessionStorage.sending=1;
        // }
        // if(!sessionStorage.my_account && sessionStorage.my_account != 1){
        //     sessionStorage.my_account=1;
        // }
        // if(!sessionStorage.account_bind && sessionStorage.account_bind != 1){
        //     sessionStorage.account_bind=1;
        // }
    };


$(function(){
    setTimeout(function(){
        $('.notice_bar').show();
    }, 1000);
    var head_search_type=null;
	var head_search_key=null;
	var search_address=null;
	var address_array={'art':'/search/articles?search_type=art','image':'/search/images?search_type=image','gzh':'/search/account?search_type=gzh','tpc':'/topic'};
    $('.search_link').click(function(){
    	head_search_type=$('.search_area li.selected').attr('kw');
		head_search_key=encodeURI($('.search_ipt').val());
		search_address=address_array[head_search_type];
    	if($('.search_ipt').val()==''){
            if (head_search_type == 'tpc') {
                window.open(search_address,'search_art');
            } else {
                window.open(search_address + '&from_nav=1', 'search_art');
            }
    	}else{
            if (head_search_type == 'tpc') {
                window.open(search_address+'/search?keyword=' + head_search_key,'search_art');
            } else {
        		window.open(search_address+'&search_key='+head_search_key,'search_art');
            }
    	}
    });
    $('.search_ipt').bind('keypress', function(event) {
        if (event.keyCode == "13") {
            $('.search_link').click();
        }
    });
    //新手向导

  	$('.new_guide').click(function(){
  		$('.guide_wrap').css('background','url(__FORJS__/images/guide/guide_bg.png) repeat-y center top');
  		sessionStorage.pagecount=1;
  		location.href="/resource/article";
  	});
  	$('.guide_jingr .xia a:first-child').click(function(){
  		sessionStorage.pagecount=1;
  	});
  	$('.guide_faxian .caoz a:first-child').click(function(){
  		$('.guide_wrap>div').hide();
		$('.guide_hecheng').fadeIn();
  	});
  	$('.guide_hecheng .caoz a:first-child').click(function(){
  		$('.guide_wrap').css('background','none');
  		$('.guide_wrap>div').hide();
		$('.guide_hechengqi').fadeIn();
		$(".sidebar").css({
            right: '0px'
        });
  	});
  	$('.guide_hechengqi .caoz a:first-child').click(function(){
  		sessionStorage.pagecount=2;
  	});
  	$('.guide_chuangz .caoz a:first-child').click(function(){
  		sessionStorage.pagecount=3;
  	});
  	$('.guide_tuis .caoz a:first-child').click(function(e){
  		if($('#register-guide').length){
  			e.preventDefault();
  			sessionStorage.pagecount=999;
  			$('.guide_wrap').hide();
			$('.guide_wrap>div').hide();
			$('body').css('overflow','');
			if($('#login_type').val()== 'oauth'){
				$('#register-guide').modal('show');
			}
  		}else{
  			sessionStorage.pagecount=4;
  		}
  	});
  	$('.guide_jingr .xia a:last-child,.guide_wrap>div .caoz a:last-child,.guide_zhangh .caoz a:first-child,.guide_jingr .close').click(function(){
  		sessionStorage.pagecount=999;
  		$('.guide_wrap').hide();
		$('.guide_wrap>div').hide();
		$('body').css('overflow','');
		if($('#login_type').val()== 'oauth'){
			$('#register-guide').modal('show');
		}
		
  	});
  	if(sessionStorage.pagecount==1&&_ulr=='/resource/article'){
  		$('.guide_wrap').fadeIn();
		$('.guide_wrap>div').hide();
		$('.guide_faxian').fadeIn();
		$('body').css('overflow','hidden');
  	}else if(sessionStorage.pagecount==1&&_ulr!='/resource/article'&&_var=='0'){
  		sessionStorage.pagecount=999;
  		$('.guide_wrap').hide();
		$('.guide_wrap>div').hide();
		$('body').css('overflow','');
  	}
  	if(sessionStorage.pagecount==2&&_ulr=='/my_mpnews'){
  		$('.guide_wrap').css('background','url(__FORJS__/images/guide/guide_bg.png) repeat-y center top');
  		$('.guide_wrap').fadeIn();
		$('.guide_wrap>div').hide();
		$('.guide_chuangz').fadeIn();
		$('body').css('overflow','hidden');
  	}else if(sessionStorage.pagecount==2&&_ulr!='/my_mpnews'){
  		sessionStorage.pagecount=999;
  		$('.guide_wrap').hide();
		$('.guide_wrap>div').hide();
		$('body').css('overflow','');
  	}
  	if(sessionStorage.pagecount==3&&_ulr=='/sending'){
  		$('.guide_wrap').fadeIn();
		$('.guide_wrap>div').hide();
		$('.guide_tuis').fadeIn();
		$('body').css('overflow','hidden');
  	}else if(sessionStorage.pagecount==3&&_ulr!='/sending'){
  		sessionStorage.pagecount=999;
  		$('.guide_wrap').hide();
		$('.guide_wrap>div').hide();
		$('body').css('overflow','');
  	}
  	if(sessionStorage.pagecount==4&&_ulr=='/my_account'){
  		var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); //operaFix
  		$('.guide_wrap').fadeIn();
		$('.guide_wrap>div').hide();
		$('.guide_zhangh').fadeIn();
		$('body').css('overflow','hidden');
		$body.scrollTop(280);
  	}else if(sessionStorage.pagecount==4&&_ulr!='/my_account'){
  		sessionStorage.pagecount=999;
  		$('.guide_wrap').hide();
		$('.guide_wrap>div').hide();
		$('body').css('overflow','');
  	}
  	if(sessionStorage.pagecount==999){
  		$('body').css('overflow','');
  	}

});

</script>


<script type="text/javascript" src="__FORJS__/js/individual/login.js"></script>